package cn.fornever.tools.db;

import cn.fornever.tools.db.assist.entity.JDBCConnectionConfig;
import cn.fornever.tools.db.assist.entity.TableInfo;
import org.junit.Assert;
import org.junit.Test;

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.util.List;

/**
 * 数据库工具类--测试
 *
 * @author ZhangAY
 */
public class DBUtilTestOracle extends DBUtilTestBase {

    private String driverClass = "oracle.jdbc.driver.OracleDriver";
    private String connectionURL = "jdbc:oracle:thin:@58.48.222.41:1522/ORCL2";
    private String userName = "SZY_HB";
    private String password = "123456";
    JDBCConnectionConfig config_ORACLE = new JDBCConnectionConfig(driverClass, connectionURL, userName, password);
    private String catalog = null;
    private String schema = "SZY_HB";
    private String tableNamePattern = null;

    @Test
    public void getDatabaseMetaData() {
        Connection connection = DBUtil.getConnection(config_ORACLE);
        DatabaseMetaData metaData = DBUtil.getDatabaseMetaData(connection);
        Assert.assertTrue(metaData != null);
        DBUtil.closeConnection(connection);
    }

    //http://www.cnblogs.com/lbangel/p/3487796.html
    @Test
    public void getTableInfo_ORACLE() {
        Connection connection = DBUtil.getConnection(config_ORACLE);
        List<TableInfo> list = getTableInfo(connection, catalog, schema, tableNamePattern, null);
        DBUtil.closeConnection(connection);
    }

}